package cn.gson.oasys.controller;

import cn.gson.oasys.pojo.AoaPlanList;
import cn.gson.oasys.service.AoaPlanListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2020/11/27.
 */
@Controller
public class AoaPlanListController {
    @Resource
    private AoaPlanListService service;

    //获取所有计划列表 分页查询 王义
    @RequestMapping("getByAllAoaPlanList")
    @ResponseBody
    public Object getByAllAoaPlanList(Integer pageNo,Integer pageSize){
        PageHelper.offsetPage((pageNo-1)*pageSize,pageSize);
        List<AoaPlanList> aoaPlanList = service.SelectByPlanList();
        PageInfo<AoaPlanList> pageInfo=new PageInfo<AoaPlanList>(aoaPlanList);
        return pageInfo;
    }

    //根据类型，标题，状态，部门进行模糊查询   王义
    @RequestMapping("getByAllAoaPlanListByOrder")
    @ResponseBody
    public List<AoaPlanList> getByAllAoaPlanListByOrder(String typeName,String title, String statusName,
                                                        String deptName){

        List<AoaPlanList> planLists = service.selectPlanListByOrder(typeName,title,statusName,deptName);
        return planLists;
    }
    //通过planID进行修改计划列表  王义
    @RequestMapping("UpdatePlanById")
    @ResponseBody
    public int UpdatePlanById(Long planId, String typeName, String title, Date createTime,
                              String planComment, Date endTime, String planSummary, String label, String statusName, String planContent){
        return service.updataPlanByPlanId(planId,typeName,title,createTime,planComment,endTime,planSummary,label,statusName,planContent);

    }
    //新增计划列表 王义
    @RequestMapping("addPlanList")
    @ResponseBody
    public int addPlanList(AoaPlanList aoaPlanList){
        return service.addPlan(aoaPlanList);
    }

    //根据planid删除计划列表 王义
    @RequestMapping("deletPlanListById")
    @ResponseBody
    public int deletPlanListById(Long planId){
        return service.delPlanListByPlanId(planId);
    }

    //分页显示所有计划报表   王义
    @RequestMapping("getAllPlanStatement")
    @ResponseBody
    public Object getAllPlanStatement(Integer pageNo,Integer pageSize){
        PageHelper.offsetPage((pageNo-1)*pageSize,pageSize);
        List<AoaPlanList> planLists = service.SelectByPlanList();
        PageInfo<AoaPlanList> pageInfo=new PageInfo<AoaPlanList>(planLists);
        return pageInfo;
    }

    //根据用户名进行模糊查询  王义
    @RequestMapping("getAllPlanByRealName")
    @ResponseBody
    public List<AoaPlanList> getAllPlanByRealName(String realName){
        List<AoaPlanList> list = service.getPlanListByRealName(realName);
        return list;
    }

}
